<!DOCTYPE html>
<html class="loginHtml">
<head>
	<meta charset="utf-8">
	<title>OA</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="icon" href="/resources/favicon.ico">
	<link rel="stylesheet" href="/resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="/resources/css/public.css" media="all" />
	<script type="text/javascript" src="/resources/js/jquery-3.3.1.min.js"></script>
</head>
<body class="loginBody">
	<form class="layui-form">
		<div class="login_face"><img src="/resources/images/face.jpg" class="userAvatar"></div>
		<div class="layui-form-item input-item">
			<label>用户名</label>
			<input type="text" placeholder="请输入用户名" autocomplete="off" name="loginname" class="layui-input" lay-verify="required">
		</div>
		<div class="layui-form-item input-item">
			<label>密码</label>
			<input type="password" placeholder="请输入密码" autocomplete="off" name="pwd" value="123456" class="layui-input" lay-verify="required">
		</div>
<!--		<div class="layui-form-item input-item" id="imgCode">-->
<!--			<label for="code">验证码</label>-->
<!--			<input type="text" placeholder="请输入验证码" autocomplete="off" id="code" class="layui-input">-->
<!--			<img src="/login/getCode" onclick="this.src=this.src+'?'">-->
<!--		</div>-->
		<div class="layui-form-item">
			<button class="layui-btn layui-block" lay-filter="login" lay-submit>登录</button>
		</div>
		<div class="layui-form-item">
			<input type="checkbox" name="rememberme" id="rememberme" title="记住我"  lay-skin="primary">
			<button class="layui-btn layui-inline layui-btn-warm" lay-filter="signup"  style="float:right">注册</button>
		</div>
	</form>
	<script type="text/javascript">



	</script>
	<script type="text/javascript" src="/resources/layui/layui.js"></script>
	<script type="text/javascript">
		layui.use(['form','layer','jquery'],function(){
			var form = layui.form,
					layer = parent.layer === undefined ? layui.layer : top.layer
			$ = layui.jquery;

			$("#rememberme").click(function(){
				$("#rememberme").val();
			})


			$(function(){
				var res = document.cookie.substring('10');
				// 判断Cookie中是否有值，有值则回显，反之就不用管了
				if(res!=null&&res!=""){
					$("[name='loginname']").val(res);
					// 这个事件可以模拟“我”直接触发登录的那个点击事件
					$("#rememberme").attr("checked","true");
					// 刷新checkbox复选框（含开关）渲染
					form.render('checkbox');
				}

			})


			//登录按钮
			form.on("submit(login)",function(data){

				var btn =  $(this);
				//设置登录按钮  为不可点击
				btn.text("登录中...").attr("disabled","disabled").addClass("layui-disabled");
				$.post("/login/login",data.field,function(rs){
					console.log(data.field);
					//设置登录按钮 恢复可点击   在前端防止 重复点击
					btn.text("登录").attr("disabled",false).removeClass("layui-disabled");
					layer.msg(rs.msg);
					if(rs.code != 200){
						layer.msg(rs.msg);
					}else{
						//跳转到templates/system/index/index.html页面
						layer.msg(rs.msg);
						location.href="/sys/index";
					}
				});
				return false;
			})

			//表单输入效果
			$(".loginBody .input-item").click(function(e){
				e.stopPropagation();
				$(this).addClass("layui-input-focus").find(".layui-input").focus();
			})
			$(".loginBody .layui-form-item .layui-input").focus(function(){
				$(this).parent().addClass("layui-input-focus");
			})
			$(".loginBody .layui-form-item .layui-input").blur(function(){
				$(this).parent().removeClass("layui-input-focus");
				if($(this).val() != ''){
					$(this).parent().addClass("layui-input-active");
				}else{
					$(this).parent().removeClass("layui-input-active");
				}
			})
		})

	</script>
	<script type="text/javascript" src="/resources/js/cache.js"></script>
</body>
</html>